package jinglei.Sci.Learn.Lambda;

import java.util.Arrays;
import java.util.List;
import java.util.Random;
import java.util.function.Function;

public class FunctionSample {
    public static void main(String[] args) {
        Function<Integer,String> randomStringFunction=l->{
            String chars="fadsfasdfasdfasdfahjkhrewtr9846124835165515552";
            StringBuilder stringBuilder=new StringBuilder();
            Random random=new Random();
            for (int i=0;i<l;i++)
            {
                int postion=random.nextInt(chars.length());
                stringBuilder.append(chars.charAt((postion)));
            }
            return  stringBuilder.toString();
        };
        String randomSttring=randomStringFunction.apply(32);
        System.out.println(randomSttring);
        List<Integer> list= Arrays.asList(1,2,3,4,56,7,78,55,344,8);

        Function<List<Integer>,Integer> maxOfList=li->{
          return li.stream().max((a,b)->a.compareTo(b)).get();
        };
        Integer maxValue= maxOfList.apply(list);
        System.out.println(maxValue);
    }
}
